home *** CD-ROM | disk | FTP | other *** search
- /*//////////////////////////////////////////////////////////////////////
- Filename: sdb-daytime.js
- Company Name: Computer Associates International, Inc.
- Legal Copyright: Copyright (c) Computer Associates International, Inc.
- Author: Ales Novak
- Product: Tiny Firewall
- Description: javascript code to manipulate time object through XMLSecDBParser COM iface
- ///////////////////////////////////////////////////////////////////////*/
-
- // requires sdb-consts.js + sdb-msgs.js
-
- ///////////////////////////////////////////////////////////////////////
- // AddPredefinedDayTimeObject - adds it to both FW and SBX at once
- // the format of the strDayTimeIntervals is "Mo#9:0-17:59|Tu#9:0-17:59|We#9:0-17:59|Th#9:0-17:59|Fr#9:0-16:59"
- function AddPredefinedDayTimeObject( strDayTimeObjectID, strDayTimeIntervals )
- {
- var bSuccess = false;
-
- // put it to FW database
- try {
- var definitionList = external.ServerParser(XM_FW).DefinitionList;
-
- var definition = definitionList.CreateDefinition();
- definition.DefinitionID = strDayTimeObjectID;
- definition.ObjectType = OT_TIME;
-
- var newItem = definition.ItemList.CreateItem();
- newItem.Content = strDayTimeIntervals;
- definition.ItemList.Insert(newItem);
-
- definitionList.Insert( definition );
-
- bSuccess = true;
- }
- catch(e) {}
-
- // put it to SBX database as well
- try {
- var definitionList = external.ServerParser(XM_SBX).DefinitionList;
-
- var definition = definitionList.CreateDefinition();
- definition.DefinitionID = strDayTimeObjectID;
- definition.ObjectType = OT_TIME;
-
- var newItem = definition.ItemList.CreateItem();
- newItem.Content = strDayTimeIntervals;
- definition.ItemList.Insert(newItem);
-
- definitionList.Insert( definition );
-
- bSuccess = true;
- }
- catch(e) {}
-
- external.Save();
-
- return (bSuccess ? SUCCESS : ErrorHandler( ERR_ADDING_TIME_OBJECT_FAILED, STR_ADDING_TIME_OBJECT_FAILED ));
- }
-
- ///////////////////////////////////////////////////////////////////////
- // DeletePredefinedDayTimeObject - removes it from both FW and SBX at once
- function DeletePredefinedDayTimeObject( strDayTimeObjectID )
- {
- var bSuccess = false;
-
- // remove it from FW database
- try {
- var definitionList = external.ServerParser(XM_FW).DefinitionList;
-
- var definition = definitionList.Get( strDayTimeObjectID );
- if (definition)
- definitionList.Remove(definition);
-
- bSuccess = true;
- }
- catch(e) {}
-
- // remove it from SBX database as well
- try {
- var definitionList = external.ServerParser(XM_SBX).DefinitionList;
-
- var definition = definitionList.Get( strDayTimeObjectID );
- if (definition)
- definitionList.Remove(definition);
-
- bSuccess = true;
- }
- catch(e) {}
-
- external.Save();
-
- return (bSuccess ? SUCCESS : ErrorHandler( ERR_DELETE_TIME_OBJECT_FAILED, STR_DELETE_TIME_OBJECT_FAILED ));
- }
-
-
-